#Introduction for working code:
Name the folder appropriately (when downloading the code from GitHub the folder will be hc_switch_cccu-main).
Attention! The downloaded project from GitHub does not contain any data files!
–> Click on Download, then select R, then follow the login –> store data in the folder specific to the R project in an extra sub-folder called RData (i.e., hc_switch_cccu-main - > RData). If you downloaded the code from GitHub, the RData folder will be already in the hc_switch_cccu-main projects folder.
–> Within the RData folder store data for wave 1 in DS0001, for wave 2 in DS0002 and so on (i.e., hc_switch_cccu-main - > RData -> DS0001 ). If you downloaded the code from GitHub, the relevant folders will be already there.
–> name the Rdata files according to the wave:
Wave 1: 37067-0001-Data (i.e., hc_switch_cccu-main - > RData -> DS0001 -> 37067-0001-Data.rda )
Wave 2: 37067-0002-Data (i.e., hc_switch_cccu-main - > RData -> DS0002 -> 37067-0002-Data.rda )
Wave 3: 37067-0003-Data (i.e., hc_switch_cccu-main - > RData -> DS0003 -> 37067-0003-Data.rda )
Wave 4: 37067-0004-Data (i.e., hc_switch_cccu-main - > RData -> DS0004 -> 37067-0004-Data.rda )
–> attention to the .rda ending when loading the data into R!
All relevant packages and versions can be seen in the section “Analyses”
run the code according to the defined order beginning with 01_ (or 0 if you want to have a look at the synthetic data) and ending with 09_ so that all data frames are created appropriately
Run the Code :) # Codebook {.tabset} ## 1. Packages and df
library(ggplot2)
theme_set(theme_bw())
library(codebook)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ lubridate 1.9.2 ✔ tibble 3.2.1
## ✔ purrr 1.0.1 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(future)
library(psych)
##
## Attache Paket: 'psych'
##
## Das folgende Objekt ist maskiert 'package:codebook':
##
## bfi
##
## Die folgenden Objekte sind maskiert von 'package:ggplot2':
##
## %+%, alpha
library(Hmisc)
##
## Attache Paket: 'Hmisc'
##
## Das folgende Objekt ist maskiert 'package:psych':
##
## describe
##
## Die folgenden Objekte sind maskiert von 'package:dplyr':
##
## src, summarize
##
## Die folgenden Objekte sind maskiert von 'package:base':
##
## format.pval, units
load("cccu_MA.RData")
cccu_MA = cccu_MA %>%
select(WAVE, switch, hc, contra_satis, hc_dur, sexual_satisfaction, sex_freq,
AGE, DEGREE_recode, POVRATE, HLTHPROB_recode, MEDPROB_recode, GAPINS_recode, TYPEINS_recode, NKIDS_t1, pregnant_between_waves, had_baby_between_waves, Avoid_r, FEELPG_recode, rel_dur_factor)
codebook(cccu_MA, missingness_report = FALSE, indent = "###")
Dataset name: cccu_MA
The dataset has N=3787 rows and 20 columns. 2285 rows have no missing values on any column.
|
###Variables
Distribution of values for WAVE
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| WAVE | factor | FALSE | 1. t1, 2. t2, 3. t3, 4. t4 |
0 | 1 | 3 | t1: 1723, t2: 1181, t3: 883, t4: 0 | NA |
Distribution of values for switch
0 missing values.
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| switch | numeric | 0 | 1 | 0 | 0 | 1 | 0.1280697 | 0.3342115 | ▇▁▁▁▁ | NA |
Distribution of values for hc
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| hc | factor | FALSE | 1. hc, 2. non_hc, 3. IUD&non_hc |
0 | 1 | 2 | hc: 2294, non: 1493, IUD: 0 | NA |
Distribution of values for contra_satis
0 missing values.
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| contra_satis | numeric | 0 | 1 | 1 | 4 | 4 | 3.486137 | 0.7016738 | ▁▁▁▅▇ | NA |
Distribution of values for hc_dur
1502 missing values.
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| hc_dur | numeric | 1502 | 0.60338 | 0 | 10 | 41 | 10.98993 | 6.753113 | ▇▇▃▁▁ | NA |
Distribution of values for sexual_satisfaction
0 missing values.
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| sexual_satisfaction | numeric | 0 | 1 | 1 | 5 | 6 | 5.016636 | 1.156752 | ▁▁▃▅▇ | NA |
Distribution of values for sex_freq
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| sex_freq | factor | FALSE | 1. No sex or once, 2. 2-5 times, 3. 6-10 times, 4. 11 or more times |
0 | 1 | 4 | 2-5: 1659, 6-1: 1036, 11 : 594, No : 498 | NA |
Distribution of values for AGE
0 missing values.
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| AGE | numeric | 0 | 1 | 18 | 27 | 39 | 28.15289 | 5.209466 | ▃▇▆▅▅ | NA |
Distribution of values for DEGREE_recode
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| DEGREE_recode | factor | FALSE | 1. no formal education, 2. 1st to 4th grade, 3. 5th/6th grade, 4. 7th/8th grade, 5. 9th grade, 6. 10th grade, 7. 11th grade, 8. 12th grade / no diploma, 9. high school diploma or equivalent, 10. some college, no degree, 11. associate degree, 12. bachelors degree, 13. masters degree, 14. professional or doctoral degree |
0 | 1 | 13 | bac: 1364, som: 924, mas: 442, hig: 421 | NA |
Distribution of values for POVRATE
0 missing values.
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| POVRATE | numeric | 0 | 1 | 14 | 282 | 1532 | 320.1458 | 231.8161 | ▇▅▁▁▁ | NA |
Distribution of values for HLTHPROB_recode
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| HLTHPROB_recode | factor | FALSE | 1. No, 2. Yes |
0 | 1 | 2 | No: 3125, Yes: 662 | NA |
Distribution of values for MEDPROB_recode
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| MEDPROB_recode | factor | FALSE | 1. No, 2. Yes |
0 | 1 | 2 | No: 3444, Yes: 343 | NA |
Distribution of values for GAPINS_recode
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| GAPINS_recode | factor | FALSE | 1. No, 2. Yes |
0 | 1 | 2 | No: 3076, Yes: 711 | NA |
Distribution of values for TYPEINS_recode
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| TYPEINS_recode | factor | FALSE | 1. No, 2. Yes |
0 | 1 | 2 | Yes: 3218, No: 569 | NA |
Distribution of values for NKIDS_t1
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| NKIDS_t1 | factor | FALSE | 1. 0, 2. 1, 3. 2, 4. 3, 5. 4 or more |
0 | 1 | 5 | 0: 2121, 1: 704, 2: 631, 3: 216 | NA |
Distribution of values for pregnant_between_waves
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| pregnant_between_waves | factor | FALSE | 1. No, 2. Yes |
0 | 1 | 2 | No: 3655, Yes: 132 | NA |
Distribution of values for had_baby_between_waves
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| had_baby_between_waves | factor | FALSE | 1. No, 2. Yes |
0 | 1 | 2 | No: 3697, Yes: 90 | NA |
Distribution of values for Avoid_r
0 missing values.
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| Avoid_r | numeric | 0 | 1 | 1 | 5 | 6 | 4.777396 | 1.55302 | ▂▂▂▃▇ | NA |
Distribution of values for FEELPG_recode
0 missing values.
| name | data_type | n_missing | complete_rate | min | median | max | mean | sd | hist | label |
|---|---|---|---|---|---|---|---|---|---|---|
| FEELPG_recode | numeric | 0 | 1 | 1 | 3 | 6 | 3.40507 | 1.689799 | ▇▃▅▃▃ | NA |
Distribution of values for rel_dur_factor
0 missing values.
| name | data_type | ordered | value_labels | n_missing | complete_rate | n_unique | top_counts | label |
|---|---|---|---|---|---|---|---|---|
| rel_dur_factor | factor | FALSE | 1. Single, 2. 0q-25q, 3. 26q-50q, 4. 51q-75q, 5. 76q-100q |
0 | 1 | 5 | Sin: 932, 0q-: 792, 26q: 760, 51q: 684 | NA |
The following JSON-LD can be found by search engines, if you share this codebook publicly on the web.
{
"name": "cccu_MA",
"datePublished": "2023-11-14",
"description": "The dataset has N=3787 rows and 20 columns.\n2285 rows have no missing values on any column.\n\n\n## Table of variables\nThis table contains variable names, labels, and number of missing values.\nSee the complete codebook for more.\n\n|name |label | n_missing|\n|:----------------------|:-----|---------:|\n|WAVE |NA | 0|\n|switch |NA | 0|\n|hc |NA | 0|\n|contra_satis |NA | 0|\n|hc_dur |NA | 1502|\n|sexual_satisfaction |NA | 0|\n|sex_freq |NA | 0|\n|AGE |NA | 0|\n|DEGREE_recode |NA | 0|\n|POVRATE |NA | 0|\n|HLTHPROB_recode |NA | 0|\n|MEDPROB_recode |NA | 0|\n|GAPINS_recode |NA | 0|\n|TYPEINS_recode |NA | 0|\n|NKIDS_t1 |NA | 0|\n|pregnant_between_waves |NA | 0|\n|had_baby_between_waves |NA | 0|\n|Avoid_r |NA | 0|\n|FEELPG_recode |NA | 0|\n|rel_dur_factor |NA | 0|\n\n### Note\nThis dataset was automatically described using the [codebook R package](https://rubenarslan.github.io/codebook/) (version 0.9.2).",
"keywords": ["WAVE", "switch", "hc", "contra_satis", "hc_dur", "sexual_satisfaction", "sex_freq", "AGE", "DEGREE_recode", "POVRATE", "HLTHPROB_recode", "MEDPROB_recode", "GAPINS_recode", "TYPEINS_recode", "NKIDS_t1", "pregnant_between_waves", "had_baby_between_waves", "Avoid_r", "FEELPG_recode", "rel_dur_factor"],
"@context": "http://schema.org/",
"@type": "Dataset",
"variableMeasured": [
{
"name": "WAVE",
"value": "1. t1,\n2. t2,\n3. t3,\n4. t4",
"@type": "propertyValue"
},
{
"name": "switch",
"@type": "propertyValue"
},
{
"name": "hc",
"value": "1. hc,\n2. non_hc,\n3. IUD&non_hc",
"@type": "propertyValue"
},
{
"name": "contra_satis",
"@type": "propertyValue"
},
{
"name": "hc_dur",
"@type": "propertyValue"
},
{
"name": "sexual_satisfaction",
"@type": "propertyValue"
},
{
"name": "sex_freq",
"value": "1. No sex or once,\n2. 2-5 times,\n3. 6-10 times,\n4. 11 or more times",
"@type": "propertyValue"
},
{
"name": "AGE",
"@type": "propertyValue"
},
{
"name": "DEGREE_recode",
"value": "1. no formal education,\n2. 1st to 4th grade,\n3. 5th/6th grade,\n4. 7th/8th grade,\n5. 9th grade,\n6. 10th grade,\n7. 11th grade,\n8. 12th grade / no diploma,\n9. high school diploma or equivalent,\n10. some college, no degree,\n11. associate degree,\n12. bachelors degree,\n13. masters degree,\n14. professional or doctoral degree",
"@type": "propertyValue"
},
{
"name": "POVRATE",
"@type": "propertyValue"
},
{
"name": "HLTHPROB_recode",
"value": "1. No,\n2. Yes",
"@type": "propertyValue"
},
{
"name": "MEDPROB_recode",
"value": "1. No,\n2. Yes",
"@type": "propertyValue"
},
{
"name": "GAPINS_recode",
"value": "1. No,\n2. Yes",
"@type": "propertyValue"
},
{
"name": "TYPEINS_recode",
"value": "1. No,\n2. Yes",
"@type": "propertyValue"
},
{
"name": "NKIDS_t1",
"value": "1. 0,\n2. 1,\n3. 2,\n4. 3,\n5. 4 or more",
"@type": "propertyValue"
},
{
"name": "pregnant_between_waves",
"value": "1. No,\n2. Yes",
"@type": "propertyValue"
},
{
"name": "had_baby_between_waves",
"value": "1. No,\n2. Yes",
"@type": "propertyValue"
},
{
"name": "Avoid_r",
"@type": "propertyValue"
},
{
"name": "FEELPG_recode",
"@type": "propertyValue"
},
{
"name": "rel_dur_factor",
"value": "1. Single,\n2. 0q-25q,\n3. 26q-50q,\n4. 51q-75q,\n5. 76q-100q",
"@type": "propertyValue"
}
]
}`
#Plots
#Correlations
#for t1
cccu_MA_t1 <- cccu_MA%>%
filter(WAVE == "t1")
cccu_MA_t1_correlations <- cccu_MA_t1 %>%
select(contra_satis, hc_dur,
sexual_satisfaction,
AGE, POVRATE, Avoid_r, FEELPG_recode)
pairs.panels(cccu_MA_t1_correlations, cex.cor = 10)
rcorr(as.matrix(cccu_MA_t1_correlations))
## contra_satis hc_dur sexual_satisfaction AGE POVRATE
## contra_satis 1.00 0.15 0.16 0.02 0.06
## hc_dur 0.15 1.00 0.01 0.25 0.15
## sexual_satisfaction 0.16 0.01 1.00 -0.03 -0.01
## AGE 0.02 0.25 -0.03 1.00 0.18
## POVRATE 0.06 0.15 -0.01 0.18 1.00
## Avoid_r 0.13 0.02 -0.03 -0.14 -0.02
## FEELPG_recode -0.06 -0.03 0.12 0.20 -0.04
## Avoid_r FEELPG_recode
## contra_satis 0.13 -0.06
## hc_dur 0.02 -0.03
## sexual_satisfaction -0.03 0.12
## AGE -0.14 0.20
## POVRATE -0.02 -0.04
## Avoid_r 1.00 -0.61
## FEELPG_recode -0.61 1.00
##
## n
## contra_satis hc_dur sexual_satisfaction AGE POVRATE
## contra_satis 1723 1032 1723 1723 1723
## hc_dur 1032 1032 1032 1032 1032
## sexual_satisfaction 1723 1032 1723 1723 1723
## AGE 1723 1032 1723 1723 1723
## POVRATE 1723 1032 1723 1723 1723
## Avoid_r 1723 1032 1723 1723 1723
## FEELPG_recode 1723 1032 1723 1723 1723
## Avoid_r FEELPG_recode
## contra_satis 1723 1723
## hc_dur 1032 1032
## sexual_satisfaction 1723 1723
## AGE 1723 1723
## POVRATE 1723 1723
## Avoid_r 1723 1723
## FEELPG_recode 1723 1723
##
## P
## contra_satis hc_dur sexual_satisfaction AGE POVRATE
## contra_satis 0.0000 0.0000 0.4981 0.0177
## hc_dur 0.0000 0.8285 0.0000 0.0000
## sexual_satisfaction 0.0000 0.8285 0.1895 0.6176
## AGE 0.4981 0.0000 0.1895 0.0000
## POVRATE 0.0177 0.0000 0.6176 0.0000
## Avoid_r 0.0000 0.5793 0.1834 0.0000 0.4026
## FEELPG_recode 0.0084 0.2867 0.0000 0.0000 0.1272
## Avoid_r FEELPG_recode
## contra_satis 0.0000 0.0084
## hc_dur 0.5793 0.2867
## sexual_satisfaction 0.1834 0.0000
## AGE 0.0000 0.0000
## POVRATE 0.4026 0.1272
## Avoid_r 0.0000
## FEELPG_recode 0.0000
#for t2
cccu_MA_t2 <- cccu_MA%>%
filter(WAVE == "t2")
cccu_MA_t2_correlations <- cccu_MA_t2 %>%
select(contra_satis, hc_dur,
sexual_satisfaction,
AGE, POVRATE, Avoid_r, FEELPG_recode)
pairs.panels(cccu_MA_t2_correlations, cex.cor = 10)
rcorr(as.matrix(cccu_MA_t2_correlations))
## contra_satis hc_dur sexual_satisfaction AGE POVRATE
## contra_satis 1.00 0.15 0.14 0.01 0.06
## hc_dur 0.15 1.00 0.04 0.20 0.16
## sexual_satisfaction 0.14 0.04 1.00 -0.05 -0.01
## AGE 0.01 0.20 -0.05 1.00 0.16
## POVRATE 0.06 0.16 -0.01 0.16 1.00
## Avoid_r 0.04 0.05 -0.08 -0.14 0.00
## FEELPG_recode 0.00 0.01 0.18 0.19 -0.04
## Avoid_r FEELPG_recode
## contra_satis 0.04 0.00
## hc_dur 0.05 0.01
## sexual_satisfaction -0.08 0.18
## AGE -0.14 0.19
## POVRATE 0.00 -0.04
## Avoid_r 1.00 -0.62
## FEELPG_recode -0.62 1.00
##
## n
## contra_satis hc_dur sexual_satisfaction AGE POVRATE
## contra_satis 1181 717 1181 1181 1181
## hc_dur 717 717 717 717 717
## sexual_satisfaction 1181 717 1181 1181 1181
## AGE 1181 717 1181 1181 1181
## POVRATE 1181 717 1181 1181 1181
## Avoid_r 1181 717 1181 1181 1181
## FEELPG_recode 1181 717 1181 1181 1181
## Avoid_r FEELPG_recode
## contra_satis 1181 1181
## hc_dur 717 717
## sexual_satisfaction 1181 1181
## AGE 1181 1181
## POVRATE 1181 1181
## Avoid_r 1181 1181
## FEELPG_recode 1181 1181
##
## P
## contra_satis hc_dur sexual_satisfaction AGE POVRATE
## contra_satis 0.0000 0.0000 0.6556 0.0531
## hc_dur 0.0000 0.2944 0.0000 0.0000
## sexual_satisfaction 0.0000 0.2944 0.1034 0.7755
## AGE 0.6556 0.0000 0.1034 0.0000
## POVRATE 0.0531 0.0000 0.7755 0.0000
## Avoid_r 0.1471 0.1944 0.0098 0.0000 0.9078
## FEELPG_recode 0.8963 0.8778 0.0000 0.0000 0.2005
## Avoid_r FEELPG_recode
## contra_satis 0.1471 0.8963
## hc_dur 0.1944 0.8778
## sexual_satisfaction 0.0098 0.0000
## AGE 0.0000 0.0000
## POVRATE 0.9078 0.2005
## Avoid_r 0.0000
## FEELPG_recode 0.0000
#for t3
cccu_MA_t3 <- cccu_MA%>%
filter(WAVE == "t3")
cccu_MA_t3_correlations <- cccu_MA_t3 %>%
select(contra_satis, hc_dur,
sexual_satisfaction,
AGE, POVRATE, Avoid_r, FEELPG_recode)
pairs.panels(cccu_MA_t3_correlations, cex.cor = 10)
rcorr(as.matrix(cccu_MA_t3_correlations))
## contra_satis hc_dur sexual_satisfaction AGE POVRATE
## contra_satis 1.00 0.17 0.14 -0.02 0.06
## hc_dur 0.17 1.00 0.03 0.11 0.12
## sexual_satisfaction 0.14 0.03 1.00 -0.01 -0.02
## AGE -0.02 0.11 -0.01 1.00 0.16
## POVRATE 0.06 0.12 -0.02 0.16 1.00
## Avoid_r 0.05 0.01 -0.07 -0.12 -0.02
## FEELPG_recode 0.01 -0.02 0.16 0.16 -0.06
## Avoid_r FEELPG_recode
## contra_satis 0.05 0.01
## hc_dur 0.01 -0.02
## sexual_satisfaction -0.07 0.16
## AGE -0.12 0.16
## POVRATE -0.02 -0.06
## Avoid_r 1.00 -0.64
## FEELPG_recode -0.64 1.00
##
## n
## contra_satis hc_dur sexual_satisfaction AGE POVRATE Avoid_r
## contra_satis 883 536 883 883 883 883
## hc_dur 536 536 536 536 536 536
## sexual_satisfaction 883 536 883 883 883 883
## AGE 883 536 883 883 883 883
## POVRATE 883 536 883 883 883 883
## Avoid_r 883 536 883 883 883 883
## FEELPG_recode 883 536 883 883 883 883
## FEELPG_recode
## contra_satis 883
## hc_dur 536
## sexual_satisfaction 883
## AGE 883
## POVRATE 883
## Avoid_r 883
## FEELPG_recode 883
##
## P
## contra_satis hc_dur sexual_satisfaction AGE POVRATE
## contra_satis 0.0000 0.0000 0.6369 0.0580
## hc_dur 0.0000 0.4937 0.0095 0.0059
## sexual_satisfaction 0.0000 0.4937 0.8171 0.5747
## AGE 0.6369 0.0095 0.8171 0.0000
## POVRATE 0.0580 0.0059 0.5747 0.0000
## Avoid_r 0.1777 0.9037 0.0373 0.0004 0.5264
## FEELPG_recode 0.7616 0.6797 0.0000 0.0000 0.0715
## Avoid_r FEELPG_recode
## contra_satis 0.1777 0.7616
## hc_dur 0.9037 0.6797
## sexual_satisfaction 0.0373 0.0000
## AGE 0.0004 0.0000
## POVRATE 0.5264 0.0715
## Avoid_r 0.0000
## FEELPG_recode 0.0000